﻿@model Proggy.Data.Entities.PublishableNode
@{
    ViewBag.Title = "Select template";

    // get allowed list
    var allowedTemplates = (IEnumerable<SelectListItem>)ViewBag.AllowedTemplates;

    // add js
    Html.AddToBackEndContent("~/Areas/Proggy/Content/Scripts/Proggy.ContentEdit.js", BackEndContentType.JavaScript);

}
<h2>@ViewBag.Title</h2>
@using (Html.BeginRouteForm(new { controller = "Content", action = "TryFinishCreate", parentNodeId = Request["ParentNodeId"] }))
{   
    <div class="proggy-form-div">
        @Html.ValidationSummary(false)
        <p>
            @Html.LabelFor(m => m.Name)
            @Html.DisplayFor(m => m.Name)
            @Html.HiddenFor(m => m.Name)
        </p>
        <p>
            @if (!string.IsNullOrEmpty(Request["ParentNodeId"]))
            {
                 @Html.LabelFor(m => m.UrlPortion)
                 @: @Html.DisplayFor(m => m.UrlPortion)
            }
            @Html.HiddenFor(m => m.UrlPortion)
        </p>
        <p>
            @Html.LabelFor(m => m.TypeAlias)
            @Html.DisplayFor(m => m.TypeAlias)
            @Html.HiddenFor(m => m.TypeAlias)
        </p>
        <p>
            @Html.LabelFor(m => m.UniqueAlias)
            @if (!string.IsNullOrEmpty(Model.UniqueAlias))
            { 
                @:@Html.DisplayFor(m => m.UniqueAlias)
            }
            else { 
                <span class="italic">[None]</span>
            }
            @Html.HiddenFor(m => m.UniqueAlias)
        </p>
        <p>
            @Html.LabelFor(m => m.Template)
            @Html.DropDownListFor(m => m.Template, allowedTemplates)
        </p>
        <p>
            <label>
                &nbsp;</label>
            <input type="submit" class="proggy-button-go" value="Back" name="WhichButton" id="Back" />
            |
            <input type="submit" class="proggy-button-go" value="Create" name="WhichButton" id="Next" />
            |
            @Html.ActionLink("Cancel", "Index", new { success = 5, selected = Request["ParentNodeId"] }, new { @class = "proggy-button-stop" })
        </p>
    </div> 
    <script type="text/javascript">
        jQuery(function () {
            var editor = new Proggy.ContentEdit();
            editor.CheckForValidationErrors();
            editor.BindUrlSlug();
        });
    </script>
}
